GtkAssistant: Redo page margins
authorMatthias Clasen <mclasen@redhat.com>
Mon, 15 Jun 2015 01:04:15 +0000 (21:04 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 15 Jun 2015 01:04:15 +0000 (21:04 -0400)
Instead of having padding outside the notebook containing
all pages, put each page in an extra box and add the padding
there. This is in preparation for allowing pages without
padding.

gtk/gtkassistant.c

index e1a52447e2fdcd59cc688caddd0c2fa006eb2fa0..21746a9f6743bdfc27175933e50bf3f4fe0fc358 100644 (file)
@@ -1109,8 +1109,8 @@ on_page_notify_visibility (GtkWidget  *widget,
 }
 
 static void
-assistant_remove_page_cb (GtkNotebook *notebook,
-                          GtkWidget *page,
+assistant_remove_page_cb (GtkNotebook  *notebook,
+                          GtkWidget    *page,
                           GtkAssistant *assistant)
 {
   GtkAssistantPrivate *priv = assistant->priv;
@@ -1118,6 +1118,15 @@ assistant_remove_page_cb (GtkNotebook *notebook,
   GList *page_node;
   GList *element;
 
+  if (GTK_IS_BOX (page))
+    {
+      GList *children;
+
+      children = gtk_container_get_children (GTK_CONTAINER (page));
+      page = GTK_WIDGET (children->data);
+      g_list_free (children);
+    }
+
   element = find_page (assistant, page);
   if (!element)
     return;
@@ -1445,12 +1454,14 @@ gtk_assistant_remove (GtkContainer *container,
                       GtkWidget    *page)
 {
   GtkAssistant *assistant = (GtkAssistant*) container;
+  GtkWidget *box;
 
   /* Forward this removal to the content notebook */
-  if (gtk_widget_get_parent (page) == assistant->priv->content)
+  box = gtk_widget_get_parent (page);
+  if (gtk_widget_get_parent (box) == assistant->priv->content)
     {
       container = (GtkContainer *) assistant->priv->content;
-      gtk_container_remove (container, page);
+      gtk_container_remove (container, box);
     }
 }
 
@@ -1743,6 +1754,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   GtkAssistantPage *page_info;
   gint n_pages;
   GtkStyleContext *context;
+  GtkWidget *box;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
   g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
@@ -1785,7 +1797,12 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->regular_title, 2 * position);
   gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->current_title, 2 * position + 1);
 
-  gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), page, NULL, position);
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_widget_show (box);
+  gtk_box_pack_start (GTK_BOX (box), page, TRUE, TRUE, 0);
+  g_object_set (box, "margin", 12, NULL);
+
+  gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position);
 
   if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
     {